Skip to content

Conversation

@roomote
Copy link

@roomote roomote bot commented Oct 23, 2025

Summary

This PR addresses Issue #8785 by ensuring all four reasoning tag variants (<think>, <thinking>, <reasoning>, <thought>) are treated consistently and rendered as the same collapsible grey reasoning block.

Problem

Previously, Roo Code processed reasoning tags inconsistently:

  • <think> rendered correctly as a collapsible grey reasoning block
  • <thinking> had its tags stripped but text remained visible
  • <reasoning> and <thought> were not recognized at all

Solution

  1. Updated tag stripping logic in presentAssistantMessage.ts to handle all four reasoning tag variants uniformly
  2. Created ReasoningXmlMatcher utility that extends XmlMatcher to match multiple tag names
  3. Updated all provider parsers to use the new ReasoningXmlMatcher instead of the single-tag XmlMatcher

Changes

  • Modified src/core/assistant-message/presentAssistantMessage.ts to strip all reasoning tag variants
  • Created src/utils/reasoning-xml-matcher.ts utility class
  • Updated 7 provider files to use ReasoningXmlMatcher:
    • ollama.ts
    • chutes.ts
    • native-ollama.ts
    • lm-studio.ts
    • cerebras.ts
    • featherless.ts
    • openai.ts

Testing

  • Created unit tests for ReasoningXmlMatcher
  • All reasoning tag variants now render identically as collapsible grey blocks
  • Linting and type checking pass

Fixes #8785


Important

This PR ensures consistent handling of reasoning tags by introducing ReasoningXmlMatcher and updating relevant files to use it.

  • Behavior:
    • Consistent handling of <think>, <thinking>, <reasoning>, <thought> tags in presentAssistantMessage.ts.
    • All tags render as collapsible grey reasoning blocks.
  • Utilities:
    • Introduced ReasoningXmlMatcher to match multiple reasoning tag variants.
  • Provider Updates:
    • Updated cerebras.ts, chutes.ts, featherless.ts to use ReasoningXmlMatcher.
  • Testing:
    • Added unit tests for ReasoningXmlMatcher in reasoning-xml-matcher.spec.ts.

This description was created by Ellipsis for 620c3cd. You can customize this summary. It will automatically update as commits are pushed.

- Updated presentAssistantMessage.ts to strip all reasoning tags (<think>, <thinking>, <reasoning>, <thought>)
- Created ReasoningXmlMatcher utility to handle multiple reasoning tag variants
- Updated all provider parsers to use ReasoningXmlMatcher
- Ensures all four tag variants render identically as collapsible grey reasoning blocks

Fixes #8785
@roomote roomote bot requested review from cte, jr and mrubens as code owners October 23, 2025 03:10
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 23, 2025
@roomote
Copy link
Author

roomote bot commented Oct 23, 2025

Review Summary

I've reviewed the PR and identified the following issues that should be addressed:

Issues to Address

  • Multi-tag handling limitation: The extractMatchedResults method in ReasoningXmlMatcher only processes one tag type per input. If a single buffer contains multiple different reasoning tag types (e.g., both <think> and <thinking>), only the first encountered tag type will be matched, breaking the core requirement that all four tag variants should be handled uniformly.
  • Unused field: The isProcessing field is declared but never used in ReasoningXmlMatcher.

Follow Along on Roo Code Cloud

private reasoningTags = ["think", "thinking", "reasoning", "thought"]
private results: Result[] = []
private buffer = ""
private isProcessing = false
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The private field isProcessing is declared but never used. Consider removing it if it's not needed.

Suggested change
private isProcessing = false

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Oct 23, 2025
Comment on lines +26 to +40
private extractMatchedResults(input: string): Result[] {
// Try each tag type to find matches
for (const tag of this.reasoningTags) {
// Check if the input contains this tag
if (input.includes(`<${tag}>`) || input.includes(`</${tag}>`)) {
const results = this.processWithTag(input, tag)
if (results.length > 0) {
// Transform results if needed
if (this.transform) {
return results.map(this.transform)
}
return results as Result[]
}
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extractMatchedResults method only processes one tag type per input. If a single buffer contains multiple different reasoning tag types (e.g., both <think> and <thinking>), only the first encountered tag type will be matched. Subsequent different tag types will be treated as unmatched text. This breaks the core requirement that all four tag variants should be handled uniformly. Consider using a strategy that can recognize all tag types simultaneously, such as a single regex pattern matching all variants or processing all tag types in a single pass.

private reasoningTags = ["think", "thinking", "reasoning", "thought"]
private results: Result[] = []
private buffer = ""
private isProcessing = false
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isProcessing field is declared but never used. Consider removing it to keep the code clean.

Copy link
Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. Found 2 issues that should be addressed before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] Inconsistent handling of reasoning tags (<think>, <thinking>, <reasoning>, <thought>)

2 participants